import request from '@/assets/common/js/utils/request';
/*------------------------数据管理---------------------------------*/
export function getmenuslist(data) {
    return request({
        url: 'menus/getlist',
        method: 'post',
        data: data,
    });
}
//创建角色
export function createrole(data) {
    return request({
        url: 'roles/registerrole',
        method: 'post',
        data: data,
    });
}
export function updaterole(data) {
    return request({
        url: `roles/updaterole/${data.id}`,
        method: 'put',
        data: data,
    });
}

export function deleterole(data) {
    return request({
        url: `role/delete/${data.id}`,
        method: 'DELETE',
    });
}

export function gettreemenu(data) {
    return request({
        url: `menus/getcustree/cus/menu`,
        method: 'GET',
    });
}

export function userTree(data) {
    return request({
        url: `user/getorgusertree`,
        method: 'get',
        params: data,
    });
}
export function getuserList(data) {
    return request({
        url: `user/getorgusertree/${data.id}`,
        method: 'get',
        params: data,
    });
}

export function getuserInfo(data) {
    return request({
        url: `roles/getbyidwithpermissions/${data.id}/permissions`,
        method: 'get',
        params: data,
    });
}

export function getuserInfomsg(data) {
    //data 不存在 是新增，反之是修改
    if(!data){
        return request({
            url: `user/getorgusertree`,
            method: 'put',
        });
    }else{
        return request({
            url: `user/getorgusertree`,
            method: 'put',
            data: data,
        });
    }

}
//分页获取角色下关联用户.
export function userinrolepage(data) {
    return request({
        url: `roles/userinrolepage/${data.id}/users`,
        method: 'post',
        data: data,
    });
}
